package video

import (
	"github.com/labstack/echo"
	auth "tacitus/library/authorized"
	errs "tacitus/library/error"
)

// 使用redis缓存观看记录
func WriteWatchRecordHandler(c echo.Context) error {
	uid := auth.CurrentUser(c).UserID
	i := new(struct{
		VideoID   int64 `json:"video_id"`
		TaskCode string `json:"task_code"`
		Progress int `json:"progress"` // 当前进度(秒)
	})
	if err := c.Bind(i); err != nil {
		return err
	}
	if i.VideoID == 0 {
		return errs.Called("视频编号不能为空")
	}
	return WriteCache(uid, i.VideoID, i.TaskCode, i.Progress)
}

